<?php
/*use template to create pages*/
include('templates/header.html');
include('templates/topMenu.html');
require_once('functions/connectDB.php');
?>

<div id="contentwrap"> 
<div id="content">
<h1>The teams available</h1>
<?php // viewgroup.php
$query1 = "select * from groups";

if($result = mysql_query($query1, $db)) {
	while($row = mysql_fetch_array($result)) {
		print " <p><h3>{$row['idgroups']}&nbsp&nbsp{$row['groupName']}</h3></p>";
		
		$query2 = "select name from students where idgroups = {$row['idgroups']}";
		$result2 = mysql_query($query2, $db);
		while ($row2 = mysql_fetch_array($result2))
		
		{
		print " <p>{$row2['name']}</p>";
		}
	}
}
	else {
		print "<p>Could not retrieve the data because:<br/>".mysql_error($db).".</p>
		<p>The query being run was: ".$query. "</p>";
	}
//mysql_close($db); //close connection
?>
</div>
<?php
 require_once('templates/sidebarStudent.php');
 ?>
<div style="clear: both;"> </div>
</div>
<?php
include('templates/footer.html'); 
?>